<?php
namespace app\admin\controller;

use app\admin\controller\BaseController;
use app\common\model\FieldModel as Field;
use think\Request;
/**
 * 
 */
class FieldController extends BaseController
{
	protected $request;
	function __construct(Request $request)
	{
		parent::__construct();
		$this->request=$request;
	}

	// 获取单个表单
	public function getFormAction(){
		$field=new Field(); 
		return $field->getForm($this->request->param());
	}

	// 排序
	public function myorderAction(){
		$id=$this->request->param('id');
		$myorder=$this->request->param('myorder');
		$field=Field::get($id);
		$res=$field->save([
			'myorder'=>$myorder
		]);
		if ($res) {
			return '成功';
		}else{
			return '失败';
		}
	}

	// 是否录入
	public function isInputAction(){
		$field=new Field();
		$res=$field->isInput($this->request->param());
		if ($res) {
			return '操作成功';
		}else{
			return $field->getError();
		}
	}

	// 生成表单
	public function createFormAction(){
		$field=new Field();
		$res=$field->createForm($this->request->param('table_name'));
	}

}